<template>
	<view class="container">
		<view class="hzimg">
			<image src="/static/hjzx.jpg"></image>
			<view class="hzText">
				{{ app.language.xg_name }}
			</view>
		</view>
		<view class="listBox">
			<view class="listText" @click="listText">
				<text>{{app.language.listText2}}</text>
			</view>
			<!-- 开具相关证明 -->
			<view class="hjzxBox">
				<view class="listItem" v-for="(item, index) in hkzxList" v-if="hkzxList.length>0">
					<view class="list" @click="handleHkzx(item)">
						<!-- <image :src="item.icon"></image> -->
						<text class="listName">{{item.name}}</text>
						<image src="/static/ms.png"></image>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	const global = getApp().globalData;
	export default {
		data() {
			return {
				rlsb: true,
				app: {
					global: global,
					name: global.appName,
					language: global.language
				},
				// 户籍证明
				hkzxList: [{
					icon: "/static/hj.png",
					path: "/pages/related/domicile",
					name: ""
				}],
				token: "",
				userInfo: {}
			}
		},
		onLoad() {
			this.hkzxList[0].name = this.app.language.hjzm
			this.getToken()
		},

		methods: {
			// 获取缓存
			getToken() {
				let that = this
				uni.getStorage({
					key: 'loginData',
					success: function(res) {
						// that.form.reportType = res.data.userInfo.peopleType
						that.token = res.data.userInfo.appToken
						that.userInfo = res.data.userInfo
						console.log('that.userInfo', that.userInfo)
					}
				});
			},
			// 点击跳转路径
			handleHkzx(item) {
				if (this.token) {
					if (this.userInfo.peopleType == "people") {
						if (!this.userInfo.userName && !this.userInfo.idcard &&
							!this.userInfo.idcardFront && !this.userInfo.idcardBack) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						} else {
							uni.navigateTo({
								url: item.path + '?name=' + item.name
							});
						}
					} else if (this.userInfo.peopleType == "police") {
						// 身份作证号的
						if (!this.userInfo.agent) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						}
						if (!this.userInfo.birthdate) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						}
						if (!this.userInfo.idcard) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						}
						if (!this.userInfo.nationality) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						}
						if (!this.userInfo.policeNumber) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						}
						if (!this.userInfo.personnelCategory) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						}
						if (!this.userInfo.workTime) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						}
						if (!this.userInfo.positionRank) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						}
						if (!this.userInfo.marriage) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						}
						if (!this.userInfo.height) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						}
						if (!this.userInfo.weight) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						}
						if (!this.userInfo.photo) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						}
						uni.navigateTo({
							url: item.path + '?name=' + item.name
						});
					}
				} else {
					uni.navigateTo({
						url: '../login/login',
					});
				}
			},
			// 跳转记录列表
			listText() {

				if (this.token) {
					if (this.userInfo.peopleType == "people") {
						if (!this.userInfo.userName && !this.userInfo.idcard &&
							!this.userInfo.idcardFront && !this.userInfo.idcardBack) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						} else {
							uni.reLaunch({
								url: '/pages/related/listText'
							});
						}
					} else if (this.userInfo.peopleType == "police") {
						// 身份作证号的
						if (!this.userInfo.agent) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						}
						if (!this.userInfo.birthdate) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						}
						if (!this.userInfo.idcard) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						}
						if (!this.userInfo.nationality) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						}
						if (!this.userInfo.policeNumber) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						}
						if (!this.userInfo.personnelCategory) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						}
						if (!this.userInfo.workTime) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						}
						if (!this.userInfo.positionRank) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						}
						if (!this.userInfo.marriage) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						}
						if (!this.userInfo.height) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						}
						if (!this.userInfo.weight) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						}
						if (!this.userInfo.photo) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						}
						uni.reLaunch({
							url: '/pages/related/listText'
						});
					}
				} else {
					uni.navigateTo({
						url: '../login/login',
					});
				}
			},
		}
	}
</script>

<style>
	.listItem {
		margin: 10rpx 0;
		border-bottom: 1px dashed #ddd;
		padding-bottom: 10rpx;
	}

	.listBox {
		padding: 0 20rpx;
	}

	.list text {
		width: 89%;
		display: inline-block;
		font-size: 26rpx;
		padding-left: 5rpx;
	}

	.list image {
		width: 30rpx;
		height: 30rpx;
		position: relative;
		top: 5rpx;
		float: right;
	}

	.hzimg image {
		width: 100%;
		height: 222rpx;
	}

	.hzText {
		position: absolute;
		top: 70rpx;
		left: 137rpx;
		font-size: 44rpx;
		color: #2f8ef9;
	}

	.hjTitle {
		font-size: 30rpx;
		margin: 20rpx 0;
		font-weight: bold;
	}

	.hjzxBox {
		margin-bottom: 15rpx;
		box-shadow: 2rpx 2rpx 20rpx #ddd;
		padding: 0 10rpx 5rpx;
	}

	.kfBox {
		background-color: #2f8ef9;
		color: #fff;
		font-size: 22rpx;
		text-align: center;
		width: 100rpx;
		height: 100rpx;
		padding: 20rpx;
		border-radius: 50%;
		box-shadow: 1px 1px 10rpx #ddd;
		position: absolute;
		bottom: 40rpx;
		right: 0;
	}

	.kfBox image {
		width: 60rpx;
		height: 60rpx;
	}

	.listText {
		font-size: 28rpx;
		color: #2f8ef9;
		margin: 15rpx 0;
		text-align: right;
		font-weight: 500;
		/* border-bottom: 1px solid #ddd; */
		padding-bottom: 10rpx;
	}

	.listText text {
		border: 1px solid #2f8ef9;
		padding: 10rpx 15rpx;
		border-radius: 6rpx;
	}
</style>